package com.test.cordova.util;

import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Build;

import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2019/1/30 0030.
 */

public class IntentUtils {

    private static final String TAG = IntentUtils.class.getSimpleName();

    public static void startActivity(Activity context, Class startActivity, Map<String,String> params){
        if (context == null || startActivity == null) {
            Logger.e(TAG,"context or activity no null!!");
            return;
        }
        Intent it =  new Intent(context,startActivity);
        if (params != null) {
            Set<String> keys = params.keySet();
            for (String key : keys) {
                it.putExtra(key,params.get(key));
                Logger.i(TAG,"key: "+key+" value: "+params.get(key));
            }
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            //5.0 场景切换动画
            context.startActivity(it, ActivityOptions.makeSceneTransitionAnimation(context).toBundle());
        } else {
            context.startActivity(it);
        }
    }


}
